package com.aaa.hospital.controller;

import com.aaa.hospital.pojo.vo.Phone;
import com.aaa.hospital.result.AjaxResult;
import com.aaa.hospital.service.EmpService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * Author:张海金
 * Description:T0D0
 * DateTime:2022/1/5 17:41
 **/
@RestController
@RequestMapping("admin")

public class EmpController {

    @Autowired
    private EmpService empService;

    @RequestMapping("login")
    public AjaxResult login(String username, String password){

        return empService.login(username, password);

    }
    @RequestMapping("getInfo")
    public AjaxResult getInfo(){
        return empService.getInfo();
    }
    @RequestMapping("sendCode")
    public AjaxResult sendCode(String telephone){
        return empService.sendCode(telephone);
    }
    @RequestMapping("register")
    public AjaxResult register(Phone p){
        return empService.register(p);
    }

    @RequestMapping("add")
    public AjaxResult add(Phone p){
        return empService.add(p);
    }

    @RequestMapping("updatePassword")
    public AjaxResult updatePassword(@Param("password") String password, @Param("newpassword") String newpassword){
        return empService.updatePassword(password,newpassword);
    }
    @RequestMapping("signin")
    public AjaxResult signin(String zhanghao, String mima){
        System.out.println(zhanghao + "---" + mima);
        return empService.signin(zhanghao, mima);
    }
    @RequestMapping("getNickname")
    public AjaxResult getNickname(){
        return empService.getNickname();
    }
    @RequestMapping("yanzheng")
    public AjaxResult yanzheng(){
        return empService.yanzheng();
    }

    @RequestMapping("verification")
    public AjaxResult verification(){
        return empService.verification();
    }


    @RequestMapping("logout")
    public AjaxResult logout(){
        return empService.logout();
    }

    @RequestMapping("quit")
    public String quit(HttpSession session){
        session.removeAttribute("emp");
        return "/ssm/index.html";
    }

    @RequestMapping("quittwo")
    public String quittwo(HttpSession session){
        session.removeAttribute("signin");
        return "/ssm/index.html";
    }

}
